## Load objects with the posterior distributions using non-informative priors

load(here("final_analyses", "output", "data",
                 "noninformative_recovery_death.RData"))

## Load objects with rma() outputs for forest plots

load(here("final_analyses", "output", "data",
                 "priors_death.RData"))

## Load objects with mean + SD of multiple priors along with
## RECOVERY data and posterior distributions

load(file = here("final_analyses", "output", "data",
                 "multiple_priors_death.RData"))

## Load objets with all the posterior for summary plot

load(here("final_analyses", "output", "data",
                 "all_posteriors_death.RData"))
## Load functions to plot

# To create summary table

source(here("final_analyses", "script", "functions", # file path
            "summary_table_death.R"))               # file name


# To plot risk distributions side-by-side

source(here("final_analyses", "script", "functions", # file path
            "risk_comparison_plot.R"))               # file name

# To plot risk difference distribution

source(here("final_analyses", "script", "functions", # file path
            "risk_difference_plot.R"))               # file name

# To plot cumulative probability of risk difference

source(here("final_analyses", "script", "functions", # file path
            "cumulative_risk_difference_plot.R"))    # file name

# To plot prior, data and posterior distributions side-by-side

source(here("final_analyses", "script", "functions", # file path
            "data_prior_posterior_plot.R"))          # file name

# To plot the posterior distribution

source(here("final_analyses", "script", "functions", # file path
            "posterior_difference_plot.R"))          # file name

# To plot the cumulative probability of the posterior distribution

source(here("final_analyses", "script", "functions", # file path
            "posterior_cumulative_plot.R"))          # file name

Summary

As stated in our pre-registered protocol: “The skeptical prior uses the evidence-based prior (EBP)’s variance, but the mean equals \(0\). The optimistic prior uses the EBP’s variance, but the mean equals \(-0.05\). Lastly, the pessimistic prior uses the EBP’s variance, but the mean equals \(0.05\).”


Regarding the mortality outcome, negative risk differences mean benefit.

# X axis
xlim_inf = -12.5
xlim_sup = 12.5
ticks_spacing = 2.5

# Assure subgroup order
# https://stackoverflow.com/questions/12774210/
# how-do-you-specifically-order-ggplot2-x-axis-instead-of-alphabetical-order

level_order = c("Pessimistic",
                "Optimistic",
                "Skeptical",
                "Evidence-based",
                "Non-informative")

p1 = all_posteriors_simple_oxygen_death %>%
  
  # make it tidy for ggplot
  pivot_longer(
    cols = c("Non-informative":"Pessimistic"),
    names_to = "dist", values_to = "samples"
  ) %>%
  
  ggplot(aes(x = 100 * samples, y = factor(dist, level = level_order))) +

  # https://mjskay.github.io/ggdist/articles/slabinterval.html
  stat_halfeye(aes(fill = stat(x < 0)),
               .width = c(0.5, 0.95)
  ) +
  scale_fill_manual(values = c("gray90", "skyblue")) +
  labs(x = "\nRisk difference (%)",
       y = "Underlying prior\n",
       title = "Simple oxygen only subgroup\n"
  ) +
  scale_x_continuous(breaks = seq(from = xlim_inf, to = xlim_sup, ticks_spacing)) +
  scale_y_discrete(expand = c(0, 0.3)) +
  theme(
    axis.ticks.x = element_blank(),
    axis.ticks.y = element_blank(),
    panel.background = element_blank(),
    panel.grid.major.x = element_line(color = "gray80", size = 0.3),
    legend.position = "none",
    plot.title.position = 'plot',
    plot.margin = margin(20, 25, 10, 20)
  ) +
  coord_cartesian(xlim = c(xlim_inf, xlim_sup))
p2 = all_posteriors_noninvasive_death %>%
  
  # make it tidy for ggplot
  pivot_longer(
    cols = c("Non-informative":"Pessimistic"),
    names_to = "dist", values_to = "samples"
  ) %>%
  
  ggplot(aes(x = 100 * samples, y = factor(dist, level = level_order))) +

  # https://mjskay.github.io/ggdist/articles/slabinterval.html
  stat_halfeye(aes(fill = stat(x < 0)),
               .width = c(0.5, 0.95)
  ) +
  scale_fill_manual(values = c("gray90", "forestgreen")) +
  labs(x = "\nRisk difference (%)",
       y = "Underlying prior\n",
       title = "Non-invasive ventilation subgroup\n"
  ) +
  scale_x_continuous(breaks = seq(from = xlim_inf, to = xlim_sup, ticks_spacing)) +
  scale_y_discrete(expand = c(0, 0.3)) +
  theme(
    axis.ticks.x = element_blank(),
    axis.ticks.y = element_blank(),
    panel.background = element_blank(),
    panel.grid.major.x = element_line(color = "gray80", size = 0.3),
    legend.position = "none",
    plot.title.position = 'plot',
    plot.margin = margin(20, 25, 10, 20)
  ) +
  coord_cartesian(xlim = c(xlim_inf, xlim_sup))
p3 = all_posteriors_invasive_death %>%
  
  # make it tidy for ggplot
  pivot_longer(
    cols = c("Non-informative":"Pessimistic"),
    names_to = "dist", values_to = "samples"
  ) %>%
  
  ggplot(aes(x = 100 * samples, y = factor(dist, level = level_order))) +

  # https://mjskay.github.io/ggdist/articles/slabinterval.html
  stat_halfeye(aes(fill = stat(x < 0)),
               .width = c(0.5, 0.95)
  ) +
  scale_fill_manual(values = c("gray90", "firebrick")) +
  labs(x = "\nRisk difference (%)",
       y = "Underlying prior\n",
       title = "Invasive mechanical ventilation subgroup\n"
  ) +
  scale_x_continuous(breaks = seq(from = xlim_inf, to = xlim_sup, ticks_spacing)) +
  scale_y_discrete(expand = c(0, 0.3)) +
  theme(
    axis.ticks.x = element_blank(),
    axis.ticks.y = element_blank(),
    panel.background = element_blank(),
    panel.grid.major.x = element_line(color = "gray80", size = 0.3),
    legend.position = "none",
    plot.title.position = 'plot',
    plot.margin = margin(20, 25, 10, 20)
  ) +
  coord_cartesian(xlim = c(xlim_inf, xlim_sup))
p1 + plot_annotation(title = "Posterior distributions on mortality",
                          theme = theme(plot.title = element_text(size = 20)))
Interval bars depict 50% and 95% credible intervals

Interval bars depict 50% and 95% credible intervals

# Summary table
table_posterior = summary_table_death(all_posteriors_simple_oxygen_death)

# Use kableExtra to have a nice table

table_posterior %>% 
  kbl(booktabs = T, align = 'c') %>% 
  kable_styling(bootstrap_options = "striped", full_width = F) %>% 
  column_spec(7, bold = T, color = "#5891BF") %>%
  add_header_above(c(" " = 3,
                     "Probability of Benefit" = 4,
                     "Probability of Harm" = 3)) %>% 
  footnote(general = "RD = Risk Difference; SD = Standard Deviation")
Probability of Benefit
Probability of Harm
Prior Mean RD SD of RD Pr(< -5%) Pr(< -2%) Pr(< -1%) Pr(< 0%) Pr(> 1%) Pr(> 2%) Pr(> 5%)
Non-informative -0.037 0.019 24 81 92 97 1 0 0
Evidence-based -0.022 0.017 6 56 76 90 3 1 0
Skeptical -0.032 0.018 15 75 89 97 1 0 0
Optimistic -0.039 0.018 26 85 95 99 0 0 0
Pessimistic -0.025 0.018 8 62 81 92 2 0 0
Note:
RD = Risk Difference; SD = Standard Deviation
p2
Interval bars depict 50% and 95% credible intervals

Interval bars depict 50% and 95% credible intervals

# Summary table
table_posterior = summary_table_death(all_posteriors_noninvasive_death)

# Use kableExtra to have a nice table

table_posterior %>% 
  kbl(booktabs = T, align = 'c') %>% 
  kable_styling(bootstrap_options = "striped", full_width = F) %>% 
  column_spec(7, bold = T, color = "forestgreen") %>%
  add_header_above(c(" " = 3,
                     "Probability of Benefit" = 4,
                     "Probability of Harm" = 3)) %>%  
  footnote(general = "RD = Risk Difference; SD = Standard Deviation")
Probability of Benefit
Probability of Harm
Prior Mean RD SD of RD Pr(< -5%) Pr(< -2%) Pr(< -1%) Pr(< 0%) Pr(> 1%) Pr(> 2%) Pr(> 5%)
Non-informative -0.044 0.024 39 84 92 97 1 0 0
Evidence-based -0.044 0.021 38 87 95 98 0 0 0
Skeptical -0.033 0.021 21 74 87 95 2 1 0
Optimistic -0.045 0.021 41 89 96 99 0 0 0
Pessimistic -0.021 0.021 8 52 70 84 7 2 0
Note:
RD = Risk Difference; SD = Standard Deviation
p3
Interval bars depict 50% and 95% credible intervals.

Interval bars depict 50% and 95% credible intervals.

# Summary table
table_posterior = summary_table_death(all_posteriors_invasive_death)

# Use kableExtra to have a nice table

table_posterior %>% 
  kbl(booktabs = T, align = 'c') %>% 
  kable_styling(bootstrap_options = "striped", full_width = F) %>% 
  column_spec(7, bold = T, color = "firebrick") %>%
  add_header_above(c(" " = 3,
                     "Probability of Benefit" = 4,
                     "Probability of Harm" = 3)) %>% 
  footnote(general = "RD = Risk Difference; SD = Standard Deviation")
Probability of Benefit
Probability of Harm
Prior Mean RD SD of RD Pr(< -5%) Pr(< -2%) Pr(< -1%) Pr(< 0%) Pr(> 1%) Pr(> 2%) Pr(> 5%)
Non-informative -0.018 0.042 22 48 57 66 25 18 5
Evidence-based -0.022 0.032 19 53 65 76 16 9 1
Skeptical -0.010 0.032 10 38 50 63 26 17 3
Optimistic -0.032 0.032 28 64 75 84 9 5 1
Pessimistic 0.011 0.032 3 16 25 36 51 39 11
Note:
RD = Risk Difference; SD = Standard Deviation

Per subgroup

Simple oxygen only

Non-informative prior

## Plot!

# I will use my own functions to standardize my plots

risk_comparison_plot(
  noninformative_recovery_simple_oxygen_death, # Data object

  ### start using quotes
  
  "gray50", # Color code for control group
  "#D3A464", # Color code for other group
  "\nRisk (%)", # X axis label
  "RECOVERY trial", # Title
  "Simple oxygen only subgroup\n", # Subtitle
  
  ### stop using quotes

  10, # X axis inferior limit
  30, # X axis superior limit
  2 # X axis spacing for ticks
)
While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

xlabel = "\nRisk difference (%)"
xlim_inf = -10
xlim_sup = 5

p1 = risk_difference_plot(
  noninformative_recovery_simple_oxygen_death, # Data object

  ## start using quotes
  "#7EBAC2", # fill color code
  xlabel, # X axis label
  ### stop using quotes

  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  2 # X axis label
) 

p2 = cumulative_risk_difference_plot(
  noninformative_recovery_simple_oxygen_death, # Data object
  xlabel, # X axis label (in quotes)
  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  1, # Spacing between ticks in X axis
  "mortality" # Outcome (within quotes)
  )
p1 + p2 + plot_annotation(
  title = "Posterior distribution: RECOVERY trial + Non-informative prior",
  subtitle = "Risk difference between groups on simple oxygen only"
)
The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

Evidence-based prior

forest(priors_simple_oxygen_death)

xlabel = "\nRisk difference (%)"

data_prior_posterior_plot(
  multiple_priors_simple_oxygen_death %>% # Output from normal_approximation()
    filter(type == "evidence-based"), 
  
  # start using quotes
           "#364D55", # Color for the prior
           "#7EBAC2", # Color for RECOVERY
           "#A65041", # Color for the posterior
           xlabel, # X axis label
           "Posterior distribution: RECOVERY + Evidence-based prior", # Title
           "Simple oxygen only subgroup", # Subtitle
           # stop using quotes
           -10, # X axis inferior limit
           20, # X axis superior limit
           5 # Spacing between ticks in X axis
  ) 
While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

xlim_inf = -8
xlim_sup = 4

p1 = posterior_difference_plot(
  multiple_priors_simple_oxygen_death %>% # Output from normal_approximation()
    filter(type == "evidence-based"), 

  ## start using quotes
  "#A65041", # fill color code
  xlabel, # X axis label
  ### stop using quotes

  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  2 # Spacing between ticks in X axis
) 

p2 = posterior_cumulative_plot(
  multiple_priors_simple_oxygen_death %>% # Output from normal_approximation()
    filter(type == "evidence-based"), 
  xlabel, # X axis label (in quotes)
  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  1, # Spacing between ticks in X axis
  "mortality" # Outcome (within quotes)
  )
p1 + p2 + plot_annotation(
  title = "Posterior distribution: RECOVERY trial + Evidence-based prior",
  subtitle = "Simple oxygen only subgroup"
)
The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

Skeptical prior

xlabel = "\nRisk difference (%)"

data_prior_posterior_plot(
  
  # Output from normal_approximation_multiple_priors()
  multiple_priors_simple_oxygen_death %>%
    filter(type == "skeptical"), 
  
  # start using quotes
           "gray60", # Color for the prior
           "#7EBAC2", # Color for RECOVERY
           "#A65041", # Color for the posterior
           xlabel, # X axis label
           "Posterior distribution: RECOVERY trial + Skeptical prior", # Title
           "Simple oxygen only subgroup", # Subtitle
           # stop using quotes
           -10, # X axis inferior limit
           10, # X axis superior limit
           5 # Spacing between ticks in X axis
  ) 
While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

xlim_inf = -8
xlim_sup = 4

p1 = posterior_difference_plot(
  
  multiple_priors_simple_oxygen_death %>% # Output from normal_approximation()
    filter(type == "skeptical"), 

  ## start using quotes
  "gray50", # fill color code
  xlabel, # X axis label
  ### stop using quotes

  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  2 # Spacing between ticks in X axis
) 

p2 = posterior_cumulative_plot(
  
  multiple_priors_simple_oxygen_death %>% # Output from normal_approximation()
    filter(type == "skeptical"), 
  
  xlabel, # X axis label (in quotes)
  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  1, # Spacing between ticks in X axis
  "mortality" # Outcome (within quotes)
  )
p1 + p2 + plot_annotation(
  title = "Posterior distribution: RECOVERY trial + Skeptical prior",
  subtitle = "Simple oxygen only subgroup"
)
The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

Optimistic prior

xlabel = "\nRisk difference (%)"

data_prior_posterior_plot(
  
  # Output from normal_approximation_multiple_priors()
  multiple_priors_simple_oxygen_death %>%
    filter(type == "optimistic"), 
  
  # start using quotes
  "#5CA881", # Color for the prior
  "#7EBAC2", # Color for RECOVERY
  "#A65041", # Color for the posterior
  xlabel, # X axis label
  "Posterior distribution: RECOVERY trial + Optimistic prior", # Title
  "Simple oxygen only subgroup", # Subtitle
  # stop using quotes
  -15, # X axis inferior limit
  5, # X axis superior limit
  5 # Spacing between ticks in X axis
) 
While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

xlim_inf = -10
xlim_sup = 2

p1 = posterior_difference_plot(
  
  multiple_priors_simple_oxygen_death %>% # Output from normal_approximation()
    filter(type == "optimistic"), 
  
  ## start using quotes
  "#5CA881", # fill color code
  xlabel, # X axis label
  ### stop using quotes
  
  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  2 # Spacing between ticks in X axis
) 

p2 = posterior_cumulative_plot(
  
  multiple_priors_simple_oxygen_death %>% # Output from normal_approximation()
    filter(type == "optimistic"), 
  
  xlabel, # X axis label (in quotes)
  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  1, # Spacing between ticks in X axis
  "mortality" # Outcome (within quotes)
)
p1 + p2 + plot_annotation(
  title = "Posterior distribution: RECOVERY trial + Optimistic prior",
  subtitle = "Simple oxygen only subgroup"
)
The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

Pessimistic prior

xlabel = "\nRisk difference (%)"

data_prior_posterior_plot(
  
  # Output from normal_approximation_multiple_priors()
  multiple_priors_simple_oxygen_death %>%
    filter(type == "pessimistic"), 
  
  # start using quotes
  "#523C84", # Color for the prior
  "#7EBAC2", # Color for RECOVERY
  "#A65041", # Color for the posterior
  xlabel, # X axis label
  "Posterior distribution: RECOVERY trial + Pessimistic prior", # Title
  "Simple oxygen only subgroup", # Subtitle
  # stop using quotes
  -10, # X axis inferior limit
  15, # X axis superior limit
  5 # Spacing between ticks in X axis
) 
While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

xlim_inf = -8
xlim_sup = 4

p1 = posterior_difference_plot(
  
  multiple_priors_simple_oxygen_death %>% # Output from normal_approximation()
    filter(type == "pessimistic"), 
  
  ## start using quotes
  "#523C84", # fill color code
  xlabel, # X axis label
  ### stop using quotes
  
  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  2 # Spacing between ticks in X axis
) 

p2 = posterior_cumulative_plot(
  
  multiple_priors_simple_oxygen_death %>% # Output from normal_approximation()
    filter(type == "pessimistic"), 
  
  xlabel, # X axis label (in quotes)
  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  1, # Spacing between ticks in X axis
  "mortality" # Outcome (within quotes)
)
p1 + p2 + plot_annotation(
  title = "Posterior distribution: RECOVERY trial + Pessimistic prior",
  subtitle = "Simple oxygen only subgroup"
)
The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

Non-invasive ventilation

Non-informative prior

## Plot!

# I will be using my own functions to standardize my plots

risk_comparison_plot(
  noninformative_recovery_non_invasive_death, # Output from normal_approximation()

  ### start using quotes
  
  "gray50", # Color code for control group
  "#D3A464", # Color code for other group
  "\nRisk (%)", # X axis label
  "RECOVERY trial", # Title
  "Non-invasive ventilation subgroup\n", # Subtitle
  
  ### stop using quotes

  28, # X axis inferior limit
  48, # X axis superior limit
  2 # Spacing between ticks in X axis
)
While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

xlabel = "\nRisk difference (%)"
xlim_inf = -12
xlim_sup = 5

p1 = risk_difference_plot(
  noninformative_recovery_non_invasive_death, # Data object

  ## start using quotes
  "#7EBAC2", # fill color code
  xlabel, # X axis label
  ### stop using quotes

  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  2 # Spacing between ticks in X axis
) 

p2 = cumulative_risk_difference_plot(
  noninformative_recovery_non_invasive_death, # Data object
  xlabel, # X axis label (in quotes)
  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  1, # Spacing between ticks in X axis
  "mortality" # Outcome (within quotes)
  )
p1 + p2 + plot_annotation(
  title = "Posterior distribution: RECOVERY trial + Non-informative prior",
  subtitle = "Risk difference between groups on non-invasive ventilation"
)
The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

Evidence-based prior

forest(priors_noninvasive_death)

data_prior_posterior_plot(
   multiple_priors_noninvasive_death %>%
    filter(type == "evidence-based"), # Output from normal_approximation()
  
  # start using quotes
           "#364D55", # Color for the prior
           "#7EBAC2", # Color for RECOVERY
           "#A65041", # Color for the posterior
           xlabel, # X axis label
           "Posterior distribution: RECOVERY + Evidence-based prior", # Title
           "Non-invasive ventilation subgroup", # Subtitle
           # stop using quotes
           -15, # X axis inferior limit
           5, # X axis superior limit
           5 # Spacing between ticks in X axis
  ) 
While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

xlim_inf = -12
xlim_sup = 4

p1 = posterior_difference_plot(
  multiple_priors_noninvasive_death %>% # Output from normal_approximation()
    filter(type == "evidence-based"), 

  ## start using quotes
  "#A65041", # fill color code
  xlabel, # X axis label
  ### stop using quotes

  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  2 # Spacing between ticks in X axis
) 

p2 = posterior_cumulative_plot(
  multiple_priors_noninvasive_death %>% # Output from normal_approximation()
    filter(type == "evidence-based"), 
  xlabel, # X axis label (in quotes)
  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  1, # Spacing between ticks in X axis
  "mortality" # Outcome (within quotes)
  )
p1 + p2 + plot_annotation(
  title = "Posterior distribution: RECOVERY trial + Evidence-based prior",
  subtitle = "Non-invasive ventilation subgroup"
)
The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

Skeptical prior

xlabel = "\nRisk difference (%)"

data_prior_posterior_plot(
  
  # Output from normal_approximation_multiple_priors()
  multiple_priors_noninvasive_death %>%
    filter(type == "skeptical"), 
  
  # start using quotes
           "gray60", # Color for the prior
           "#7EBAC2", # Color for RECOVERY
           "#A65041", # Color for the posterior
           xlabel, # X axis label
           "Posterior distribution: RECOVERY trial + Skeptical prior", # Title
           "Non-invasive ventilation subgroup", # Subtitle
           # stop using quotes
           -10, # X axis inferior limit
           10, # X axis superior limit
           5 # Spacing between ticks in X axis
  ) 
While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

xlim_inf = -10
xlim_sup = 4

p1 = posterior_difference_plot(
  
  multiple_priors_noninvasive_death %>% # Output from normal_approximation_multiple_priors()
    filter(type == "skeptical"), 

  ## start using quotes
  "gray50", # fill color code
  xlabel, # X axis label
  ### stop using quotes

  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  2 # Spacing between ticks in X axis
) 

p2 = posterior_cumulative_plot(
  
  multiple_priors_noninvasive_death %>% # Output from normal_approximation_multiple_priors()
    filter(type == "skeptical"), 
  
  xlabel, # X axis label (in quotes)
  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  1, # Spacing between ticks in X axis
  "mortality" # Outcome (within quotes)
  )
p1 + p2 + plot_annotation(
  title = "Posterior distribution: RECOVERY trial + Skeptical prior",
  subtitle = "Non-invasive ventilation subgroup"
)
The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

Optimistic prior

xlabel = "\nRisk difference (%)"

data_prior_posterior_plot(
  
  # Output from normal_approximation_multiple_priors()
  multiple_priors_noninvasive_death %>%
    filter(type == "optimistic"), 
  
  # start using quotes
  "#5CA881", # Color for the prior
  "#7EBAC2", # Color for RECOVERY
  "#A65041", # Color for the posterior
  xlabel, # X axis label
  "Posterior distribution: RECOVERY trial + Optimistic prior", # Title
  "Non-invasive ventilation subgroup", # Subtitle
  # stop using quotes
  -15, # X axis inferior limit
  5, # X axis superior limit
  5 # Spacing between ticks in X axis
) 
While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

xlim_inf = -10
xlim_sup = 2

p1 = posterior_difference_plot(
  
  multiple_priors_noninvasive_death %>% # Output from normal_approximation_multiple_priors()
    filter(type == "optimistic"), 
  
  ## start using quotes
  "#5CA881", # fill color code
  xlabel, # X axis label
  ### stop using quotes
  
  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  2 # Spacing between ticks in X axis
) 

p2 = posterior_cumulative_plot(
  
  multiple_priors_noninvasive_death %>% # Output from normal_approximation_multiple_priors()
    filter(type == "optimistic"), 
  
  xlabel, # X axis label (in quotes)
  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  1, # Spacing between ticks in X axis
  "mortality" # Outcome (within quotes)
)
p1 + p2 + plot_annotation(
  title = "Posterior distribution: RECOVERY trial + Optimistic prior",
  subtitle = "Non-invasive ventilation subgroup"
)
The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

Pessimistic prior

xlabel = "\nRisk difference (%)"

data_prior_posterior_plot(
  
  # Output from normal_approximation_multiple_priors()
  multiple_priors_noninvasive_death %>%
    filter(type == "pessimistic"), 
  
  # start using quotes
  "#523C84", # Color for the prior
  "#7EBAC2", # Color for RECOVERY
  "#A65041", # Color for the posterior
  xlabel, # X axis label
  "Posterior distribution: RECOVERY trial + Pessimistic prior", # Title
  "Non-invasive ventilation subgroup", # Subtitle
  # stop using quotes
  -10, # X axis inferior limit
  15, # X axis superior limit
  5 # Spacing between ticks in X axis
) 
While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

xlim_inf = -8
xlim_sup = 4

p1 = posterior_difference_plot(
  
  multiple_priors_noninvasive_death %>% # Output from normal_approximation_multiple_priors()
    filter(type == "pessimistic"), 
  
  ## start using quotes
  "#523C84", # fill color code
  xlabel, # X axis label
  ### stop using quotes
  
  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  2 # Spacing between ticks in X axis
) 

p2 = posterior_cumulative_plot(
  
  multiple_priors_noninvasive_death %>% # Output from normal_approximation_multiple_priors()
    filter(type == "pessimistic"), 
  
  xlabel, # X axis label (in quotes)
  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  1, # Spacing between ticks in X axis
  "mortality" # Outcome (within quotes)
)
p1 + p2 + plot_annotation(
  title = "Posterior distribution: RECOVERY trial + Pessimistic prior",
  subtitle = "Non-invasive ventilation subgroup"
)
The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

Invasive mechanical ventilation

Non-informative prior

## Plot!

# I will be using my own functions to standardize my plots

risk_comparison_plot(
  noninformative_recovery_invasive_death, # Data object

  ### start using quotes
  
  "gray50", # Color code for control group
  "#D3A464", # Color code for other group
  "\nRisk (%)", # X axis label
  "RECOVERY trial", # Title
  "Invasive mechanical ventilation subgroup\n", # Subtitle
  
  ### stop using quotes

  36, # X axis inferior limit
  58, # X axis superior limit
  2 # Spacing between ticks in X axis
) + 
  
  # Extra function to better limits the axis in this case
  coord_cartesian(c(36, 58))
While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

xlabel = "\nRisk difference (%)"
xlim_inf = -16
xlim_sup = 12

p1 = risk_difference_plot(
  noninformative_recovery_invasive_death, # Data object

  ## start using quotes
  "#7EBAC2", # fill color code
  xlabel, # X axis label
  ### stop using quotes

  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  4 # Spacing between ticks in X axis
) 

p2 = cumulative_risk_difference_plot(
  noninformative_recovery_invasive_death, # Data object
  xlabel, # X axis label (in quotes)
  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  2, # Spacing between ticks in X axis
  "mortality" # Outcome (within quotes)
  )
p1 + p2 + plot_annotation(
  title = "Posterior distribution: RECOVERY trial + Non-informative prior",
  subtitle = "Risk difference between groups on invasive mechanical ventilation"
)
The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

Evidence-based prior

forest(priors_invasive_death)

data_prior_posterior_plot(
  multiple_priors_invasive_death %>%
    filter(type == "evidence-based"), # Output from normal_approximation_multiple_priors()
  
  # start using quotes
           "#364D55", # Color for the prior
           "#7EBAC2", # Color for RECOVERY
           "#A65041", # Color for the posterior
           xlabel, # X axis label
           "Posterior distribution: RECOVERY + Evidence-based prior", # Title
           "Invasive mechanical ventilation subgroup", # Subtitle
           # stop using quotes
           -15, # X axis inferior limit
           10, # X axis superior limit
           5 # Spacing between ticks in X axis
  ) 
While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

xlabel = "\nRisk difference (%)"
xlim_inf = -12
xlim_sup = 8

p1 = posterior_difference_plot(
  multiple_priors_invasive_death %>% # Output from normal_approximation_multiple_priors()
    filter(type == "evidence-based"), 

  ## start using quotes
  "#A65041", # fill color code
  xlabel, # X axis label
  ### stop using quotes

  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  2 # Spacing between ticks in X axis
) 

p2 = posterior_cumulative_plot(
  multiple_priors_invasive_death %>% # Output from normal_approximation_multiple_priors()
    filter(type == "evidence-based"), 
  xlabel, # X axis label (in quotes)
  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  2, # Spacing between ticks in X axis
  "mortality" # Outcome (within quotes)
  )
p1 + p2 + plot_annotation(
  title = "Posterior distribution: RECOVERY trial + Evidence-based prior",
  subtitle = "Invasive mechanical ventilation subgroup"
)
The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

Skeptical prior

xlabel = "\nRisk difference (%)"

data_prior_posterior_plot(
  
  # Output from normal_approximation_multiple_priors()
  multiple_priors_invasive_death %>%
    filter(type == "skeptical"), 
  
  # start using quotes
           "gray60", # Color for the prior
           "#7EBAC2", # Color for RECOVERY
           "#A65041", # Color for the posterior
           xlabel, # X axis label
           "Posterior distribution: RECOVERY trial + Skeptical prior", # Title
           "Invasive mechanical ventilation subgroup", # Subtitle
           # stop using quotes
           -10, # X axis inferior limit
           10, # X axis superior limit
           5 # Spacing between ticks in X axis
  ) 
While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

xlim_inf = -12
xlim_sup = 8

p1 = posterior_difference_plot(
  
  multiple_priors_invasive_death %>% # Output from normal_approximation_multiple_priors()
    filter(type == "skeptical"), 

  ## start using quotes
  "gray50", # fill color code
  xlabel, # X axis label
  ### stop using quotes

  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  4 # Spacing between ticks in X axis
) 

p2 = posterior_cumulative_plot(
  
  multiple_priors_invasive_death %>% # Output from normal_approximation_multiple_priors()
    filter(type == "skeptical"), 
  
  xlabel, # X axis label (in quotes)
  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  2, # Spacing between ticks in X axis
  "mortality" # Outcome (within quotes)
  )
p1 + p2 + plot_annotation(
  title = "Posterior distribution: RECOVERY trial + Skeptical prior",
  subtitle = "Invasive mechanical ventilation subgroup"
)
The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

Optimistic prior

xlabel = "\nRisk difference (%)"

data_prior_posterior_plot(
  
  # Output from normal_approximation_multiple_priors()
  multiple_priors_invasive_death %>%
    filter(type == "optimistic"), 
  
  # start using quotes
  "#5CA881", # Color for the prior
  "#7EBAC2", # Color for RECOVERY
  "#A65041", # Color for the posterior
  xlabel, # X axis label
  "Posterior distribution: RECOVERY trial + Optimistic prior", # Title
  "Invasive mechanical ventilation subgroup", # Subtitle
  # stop using quotes
  -15, # X axis inferior limit
  10, # X axis superior limit
  5 # Spacing between ticks in X axis
) 
While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

xlim_inf = -12
xlim_sup = 8

p1 = posterior_difference_plot(
  
  multiple_priors_invasive_death %>% # Output from normal_approximation_multiple_priors()
    filter(type == "optimistic"), 
  
  ## start using quotes
  "#5CA881", # fill color code
  xlabel, # X axis label
  ### stop using quotes
  
  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  4 # Spacing between ticks in X axis
) 

p2 = posterior_cumulative_plot(
  
  multiple_priors_invasive_death %>% # Output from normal_approximation_multiple_priors()
    filter(type == "optimistic"), 
  
  xlabel, # X axis label (in quotes)
  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  2, # Spacing between ticks in X axis
  "mortality" # Outcome (within quotes)
)
p1 + p2 + plot_annotation(
  title = "Posterior distribution: RECOVERY trial + Optimistic prior",
  subtitle = "Invasive mechanical ventilation subgroup"
)
The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

Pessimistic prior

xlabel = "\nRisk difference (%)"

data_prior_posterior_plot(
  
  # Output from normal_approximation_multiple_priors()
  multiple_priors_invasive_death %>%
    filter(type == "pessimistic"), 
  
  # start using quotes
  "#523C84", # Color for the prior
  "#7EBAC2", # Color for RECOVERY
  "#A65041", # Color for the posterior
  xlabel, # X axis label
  "Posterior distribution: RECOVERY trial + Pessimistic prior", # Title
  "Invasive mechanical ventilation subgroup", # Subtitle
  # stop using quotes
  -10, # X axis inferior limit
  15, # X axis superior limit
  5 # Spacing between ticks in X axis
) 
While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

While the darker shaded area depicts the 50% credible interval (CI), the interval bar depicts the 95% CI.

xlim_inf = -12
xlim_sup = 12

p1 = posterior_difference_plot(
  
  multiple_priors_invasive_death %>% # Output from normal_approximation_multiple_priors()
    filter(type == "pessimistic"), 
  
  ## start using quotes
  "#523C84", # fill color code
  xlabel, # X axis label
  ### stop using quotes
  
  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  4 # Spacing between ticks in X axis
) 

p2 = posterior_cumulative_plot(
  
  multiple_priors_invasive_death %>% # Data object
    filter(type == "pessimistic"), 
  
  xlabel, # X axis label (in quotes)
  xlim_inf, # X axis inferior limit
  xlim_sup, # X axis superior limit
  2, # Spacing between ticks in X axis
  "mortality" # Outcome (within quotes)
)
p1 + p2 + plot_annotation(
  title = "Posterior distribution: RECOVERY trial + Pessimistic prior",
  subtitle = "Invasive mechanical ventilation subgroup"
)
The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.

The interval bar depicts the 95% credible interval. The cumulative posterior distribution corresponds to the probabilities that the risk difference (RD) is less than or equal to the effect size on the X‐axis.



sessionInfo()
## R version 4.0.4 (2021-02-15)
## Platform: x86_64-apple-darwin17.0 (64-bit)
## Running under: macOS Catalina 10.15.7
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] kableExtra_1.3.4 metafor_2.4-0    Matrix_1.3-2     here_1.0.1      
##  [5] patchwork_1.1.1  ggdist_2.4.0     tidybayes_2.3.1  forcats_0.5.1   
##  [9] stringr_1.4.0    dplyr_1.0.5      purrr_0.3.4      readr_1.4.0     
## [13] tidyr_1.1.3      tibble_3.1.1     ggplot2_3.3.3    tidyverse_1.3.1 
## 
## loaded via a namespace (and not attached):
##  [1] httr_1.4.2            sass_0.3.1            viridisLite_0.4.0    
##  [4] jsonlite_1.7.2        rdocsyntax_0.4.1.9000 modelr_0.1.8         
##  [7] bslib_0.2.4           assertthat_0.2.1      distributional_0.2.2 
## [10] highr_0.9             cellranger_1.1.0      yaml_2.2.1           
## [13] pillar_1.6.0          backports_1.2.1       lattice_0.20-41      
## [16] glue_1.4.2            arrayhelpers_1.1-0    digest_0.6.27        
## [19] rvest_1.0.0           colorspace_2.0-0      htmltools_0.5.1.1    
## [22] plyr_1.8.6            pkgconfig_2.0.3       broom_0.7.6          
## [25] svUnit_1.0.3          haven_2.4.0           webshot_0.5.2        
## [28] scales_1.1.1          svglite_2.0.0         generics_0.1.0       
## [31] farver_2.1.0          ellipsis_0.3.1        cachem_1.0.4         
## [34] withr_2.4.1           cli_2.4.0             magrittr_2.0.1       
## [37] crayon_1.4.1          readxl_1.3.1          memoise_2.0.0        
## [40] evaluate_0.14         fs_1.5.0              fansi_0.4.2          
## [43] nlme_3.1-152          xml2_1.3.2            tools_4.0.4          
## [46] hms_1.0.0             lifecycle_1.0.0       V8_3.4.0             
## [49] munsell_0.5.0         reprex_2.0.0          compiler_4.0.4       
## [52] jquerylib_0.1.3       systemfonts_1.0.1     rlang_0.4.10         
## [55] grid_4.0.4            rstudioapi_0.13       rmarkdown_2.7        
## [58] gtable_0.3.0          DBI_1.1.1             curl_4.3             
## [61] R6_2.5.0              lubridate_1.7.10      knitr_1.32           
## [64] fastmap_1.1.0         utf8_1.2.1            rprojroot_2.0.2      
## [67] stringi_1.5.3         Rcpp_1.0.6            vctrs_0.3.7          
## [70] dbplyr_2.1.1          tidyselect_1.1.0      xfun_0.22            
## [73] coda_0.19-4